import Dep from "./dep"

export default class Watcher {
  constructor(vm, key, updateFn) {
    this.vm = vm
    this.key = key
    this.updateFn = updateFn

    // 读一下当前key，触发依赖收集
    Dep.target = this
    console.log(vm[key]);
    Dep.target = null
  }
  // 未来会被dep调
  update() {
    this.updateFn.call(this.vm, this.vm[this.key])
  }

}